asm
  ld sp,$C7FF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $C010
dim seed as uinteger at $C012
dim ee0 as uinteger at $C014
dim ee1 as uinteger at $C016
dim ee2 as uinteger at $C018
dim ex3 as uinteger at $C01A
dim eex as uinteger at $C01C
dim eey as uinteger at $C01E

seed=0

sub sanremoputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte):
  poke $8000+typ1*48+txp1,tch1
  end sub

for ee0=0 to 37
  for ee1=0 to 47
    seed=smsrnd(seed)
    sanremoputchar(ee1,ee0,seed band 15)
    'pacmandelay(1000)
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    sanremoputchar(ee1+31,ee0+21,ee0*16+ee1)
    next:next

eee=0:eex=8:eey=8
do
sanremoputchar(1,1,48+int(eee/10000) mod 10)
sanremoputchar(2,1,48+int(eee/1000) mod 10)
sanremoputchar(3,1,48+int(eee/100) mod 10)
sanremoputchar(4,1,48+int(eee/10) mod 10)
sanremoputchar(5,1,48+eee mod 10)

ee0=in(1) bxor $FF
sanremoputchar(3,3,48+int(ee0/100) mod 10)
sanremoputchar(4,3,48+int(ee0/10) mod 10)
sanremoputchar(5,3,48+ee0 mod 10)

eex=eex+((ee0 band 8)/8)-((ee0 band 1)/1)
eey=eey+((ee0 band 16)/16)-((ee0 band 32)/32)

sanremoputchar(eex,eey,eee band 127)

ee0=in(2) bxor $FF
sanremoputchar(3,4,48+int(ee0/100) mod 10)
sanremoputchar(4,4,48+int(ee0/10) mod 10)
sanremoputchar(5,4,48+ee0 mod 10)



eee=eee+1
loop

'-------------------------------------------------------------------------------

do

for eee=$8000 to $87FF
  seed=smsrnd(seed)
  poke eee,seed
  next

loop

do:loop

'-------------------------------------------------------------------------------


'- static ADDRESS_MAP_START( sanremo_map, AS_PROGRAM, 8, sanremo_state )
'- AM_RANGE(0x0000, 0x7fff) AM_ROM
'- AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(sanremo_videoram_w) AM_SHARE("videoram")  // 2x 76C28 (1x accessed directly, latched bank written to other like subsino etc.)
'- AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_SHARE("nvram")                               // battery backed UM6116
'- ADDRESS_MAP_END

'- static ADDRESS_MAP_START( sanremo_portmap, AS_IO, 8, sanremo_state )
'- ADDRESS_MAP_GLOBAL_MASK(0xff)
'- AM_RANGE(0x01, 0x01) AM_READ_PORT("IN0")
'- AM_RANGE(0x02, 0x02) AM_READ_PORT("IN1")
'- AM_RANGE(0x04, 0x04) AM_DEVWRITE("crtc", mc6845_device, address_w)
'- AM_RANGE(0x05, 0x05) AM_WRITE(lamps_w)
'- AM_RANGE(0x14, 0x14) AM_DEVREADWRITE("crtc", mc6845_device, register_r, register_w)
'- AM_RANGE(0x17, 0x17) AM_DEVWRITE("ay8910", ay8910_device, data_w)
'- AM_RANGE(0x24, 0x24) AM_WRITE(banksel_w)
'- AM_RANGE(0x27, 0x27) AM_DEVREAD("ay8910", ay8910_device, data_r)
'- AM_RANGE(0x37, 0x37) AM_DEVWRITE("ay8910", ay8910_device, address_w)
'- ADDRESS_MAP_END


